package com.example.transfer2;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class SelectionpcmainActivity extends Activity {

	public String host;
	public String user;
	public String password;
	public int port;
	public boolean work = true;
	private EditText editHost;
	private EditText editUser;
	private EditText editPassword;
	private EditText editPort;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.selectionpcmain);
		editHost = (EditText)findViewById(R.id.hostnamepc);
		editUser = (EditText)findViewById(R.id.usernamepc);
		editPassword = (EditText)findViewById(R.id.passwordpc);
		editPort = (EditText)findViewById(R.id.portpc);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.selectionpcmain, menu);
		return true;
	}

	public void connectToPCFtp(View view){
		host = editHost.getText().toString();
		user = editUser.getText().toString();
		password = editPassword.getText().toString();
		port = Integer.parseInt(editPort.getText().toString());
		try {
			new FTP(host, user, password, port);
			work=true;
		} catch (Exception e) {
			editHost.setText("failed",TextView.BufferType.EDITABLE);
			editUser.setText("failed",TextView.BufferType.EDITABLE);
			e.printStackTrace();
			return;
		}
		Intent intent = new Intent(SelectionpcmainActivity.this,PcFtpconnect.class);
		startActivity(intent);
	}
	
	
}